home *** CD-ROM | disk | FTP | other *** search
- class CBase
- {
- public:
- CBase() { m_n=0;}
- virtual ~CBase() { } ;
- void SetN(int n) {m_n = n;}
- int GetN() {return m_n;}
-
- CBase operator-(const CBase & base) const;
- const CBase & operator+=(int n);
- const CBase & operator-=(int n);
- const CBase & operator++(); //prefix ++ operator
- CBase operator++(int); //postfix ++ operator
- int operator==(const CBase& base) const;
- private:
- int m_n;
- };
-
- class CDerived : public CBase
- {
- public:
- CDerived() {};
- const CDerived& operator=(const CDerived& derived);
- };
-
- void main()
- {
- CBase b1, b2;
- CDerived d1, d2;
-
- b1.SetN(5);
- b2.SetN(10);
- d1.SetN(7);
- d2.SetN(12);
-
- CBase b3;
-
- CDerived d3;
- d3 = d2 - d1;
- }
-